<!DOCTYPE html>
<html lang="en">
 
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>visit video</title>
</head>
 
<body>
    <div id="videoBtn" style="max-width:500px;">
        <video controls="false"  muted="muted" id="video1" name="media" style="width:500px; height: 200px;">
            <source src="http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4" type="video/mp4">
        </video>
    </div>
    <script>
        var myVideo = document.getElementById("video1");
        var videoBtn = document.getElementById("videoBtn");
        myVideo.loop = true
        videoBtn.onmouseleave = function () {
            myVideo.pause();
        }
        videoBtn.onmousemove = function () {
            myVideo.play();
        }
        function getVideoTime() {
            if (document.getElementById('video1')) {
                let videoPlayer = document.getElementById('video1');
                videoPlayer.addEventListener('timeupdate', function () {
                    console.log(`当前的时间点是${videoPlayer.currentTime},视频长度是${videoPlayer.duration}`);
                    if (videoPlayer.currentTime > 11) {
                        myVideo.pause();
                        videoPlayer.currentTime = 0
                    }
                }, false)
            }
        }
        getVideoTime();
    </script>
    <a href="/">return</a>
</body>
 
</html>
